|
|
|
|
|
|
|
A procedure may be either private or public. A private procedure can be called only by other procedures within the same form, standard module, or class module. A public procedure can be called from any other procedure outside the module. For code in a standard module, a public procedure is global to the entire application. For code in a form or class module, a public procedure is a method that applies to the object. |
|
|
|
|
|
|
|
|
To create a procedure, you first need to decide what the procedure will do. Next, you decide what the scope of the procedure will beprivate or public. There are a couple of different methods you can use to create a new procedure. First, you must be in a code window in a module. Next, you select Tools, Add Procedures to display a dialog box that prompts you for the name of a procedure or function. Figure 9.1 shows what this dialog box looks like. |
|
|
|
|
|
|
|
|
Figure 9.1
The Add Procedure dialog box. |
|
|
|
|
|
|
|
|
In this dialog box, you input the name of a procedure and then select the type of procedure you want to create. You may select either Sub or Function for this chapter. In later chapters, youll learn about the other two types. You also select the scope of the procedureeither Public or Private. After you input the name and click the OK button, youll see that a stub of the procedure name will be input into the code window. For example, if you input the name EmployeeDisplay and click the Private scope, youll see the following stub in the code window: |
|
|
|
 |
|
|
|
|
Private Sub EmployeeDisplay ()
End Sub |
|
|
|
|
|